using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Account.Dto;
using JTZY.Model.Account;
using JTZY.Service.Account.IAccountService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2024-11-21
namespace JTZY.Admin.WebApi.Controllers.Account
{
    /// <summary>
    /// 线下收款账号
    /// </summary>
    [Verify]
    [Route("account/Offlineaccount")]
    public class OfflineaccountController : BaseController
    {
        /// <summary>
        /// 线下收款账号接口
        /// </summary>
        private readonly IOfflineaccountService _OfflineaccountService;

        public OfflineaccountController(IOfflineaccountService OfflineaccountService)
        {
            _OfflineaccountService = OfflineaccountService;
        }

        /// <summary>
        /// 查询线下收款账号列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "offlineaccount:list")]
        public IActionResult QueryOfflineaccount([FromQuery] OfflineaccountQueryDto parm)
        {
            var response = _OfflineaccountService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询线下收款账号详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "offlineaccount:query")]
        public IActionResult GetOfflineaccount(int Id)
        {
            var response = _OfflineaccountService.GetInfo(Id);
            
            var info = response.Adapt<OfflineaccountDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加线下收款账号
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "offlineaccount:add")]
        [Log(Title = "线下收款账号", BusinessType = BusinessType.INSERT)]
        public IActionResult AddOfflineaccount([FromBody] OfflineaccountDto parm)
        {
            var modal = parm.Adapt<Offlineaccount>().ToCreate(HttpContext);

            var response = _OfflineaccountService.AddOfflineaccount(modal);

            return SUCCESS(response);
        }

    }
}